<?php
/*
 * 
 * */
class CLogData{
	public function addlog($str, $filename = 'log.log') {
		// logfile
		$logFile = ROOT_DIR .'logs/'. $filename;
		//time		
		$max_filesize = 10 * 1024 * 1024;
		if (file_exists($logFile) && filesize ( $logFile ) > $max_filesize) {
			rename ( $logFile, str_replace ( '.log', '_' . date ( 'YmdHis' ) . '.log', $logFile ) );
		}
		$handle = fopen ( $logFile, "a" );
		$fwrite = fwrite ( $handle, "$str \n" );
		fclose ( $handle );
	}
}

function CLogData(){
	return new CLogData();
}